-- @owner: zou_jialiang050
-- @date: 2024-08-06
-- @testpoint: enum关键字测试，部分测试点合理报错

@conn PrimaryDbBmode;
--step1: 创建表; expect:成功
drop table if exists t_enum_0046_01;
create  table t_enum_0046_01(col1 enum('x-small', 'small', 'medium', 'large', 'x-large'));

--step2: enum作为表名; expect:删除报错，创建报错
drop table if exists enum;
create  table enum(col1 enum('x-small', 'small', 'medium', 'large', 'x-large'));

--step3: enum作为列名,不加双引号; expect:失败
drop table if exists t_enum_0046_02;
create  table t_enum_0046_02(
enum enum('x-small', 'small', 'medium', 'large', 'x-large'));

--step4: enum作为列名,加双引号; expect:成功
drop table if exists t_enum_0046_02;
create  table t_enum_0046_02(
"enum" enum('x-small', 'small', 'medium', 'large', 'x-large'));

--step4: enum作为索引名; expect:失败
create index public.enum on t_enum_0046(col1);

--step5: enum作为视图名; expect:失败
create or replace view enum as select col1 from t_enum_0046;

--step6: enum作为数据库名; expect:失败
drop database if exists enum;
create database enum;

--step7: enum作为外部数据源名; expect:失败
drop data source if exists enum;
create data source enum;

--step8: enum作为自定义函数名; expect:失败
create function enum(i integer)
returns integer
as $$
begin
    return i+1;
end;
$$ language plpgsql;
/
--step9: enum作为存储过程名; expect:失败
create or replace  procedure enum(
section     number(6),
salary_sum out number(8,2),
staffs_count out integer)
is
begin
   select sum(salary), count(*) into salary_sum, staffs_count from staffs where section_id = section;
end;
/
--step10: enum作为角色名; expect:失败
drop role if exists enum;
create role enum with password 'gauss@123';
drop role enum;

--step11: enum作为用户组名; expect:失败
drop group if exists enum;
create group enum with password 'gauss@123';
drop group enum;

--step12: enum作为模式名; expect:失败
drop schema if exists enum;
create schema enum;
drop schema enum;

--step13: enum作为序列名; expect:失败
create sequence public.enum start 100 cache 50;
drop sequence public.enum;

--step14: enum作为用户名; expect:失败
drop user if exists enum;
create user enum password 'bigdata@123';
drop user enum;

--step15: 清理环境; expect:成功
drop table if exists t_enum_0046 cascade;